package top.go2do.common.module;

import java.time.LocalDateTime;

import jakarta.persistence.*;
import lombok.Data;

/**
 * @author xingyuji
 * @date 2025/3/17 06:17
 * @description 业务系统应用表
 */
@Entity
@Table(name = "application", uniqueConstraints = {
        @UniqueConstraint(name = "idx_unique_app_name", columnNames ={"app_name"})
})
@Data
public class ApplicationPO {

    @Id
    @Column(name = "app_id", columnDefinition = "VARCHAR(32) COMMENT '系统应用唯一标识（如client_id）'")
    private String appId;

    @Column(name = "app_secret", nullable = false, columnDefinition = "CHAR(32) COMMENT 'HMAC-SHA256加密后的密钥'")
    private String appSecret;

    @Column(name = "app_name", nullable = false, columnDefinition = "VARCHAR(50) COMMENT '系统名称'")
    private String appName;

    @Column(name = "status", nullable = false, columnDefinition = "TINYINT UNSIGNED DEFAULT 1 COMMENT '1正常,2冻结,3已注销'")
    private Integer status;

    @Column(name = "created_at", nullable = false, insertable = false, updatable = false,
            columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间'")
    private LocalDateTime createdAt;

    @Column(name = "created_by", nullable = false,
            columnDefinition = "BIGINT UNSIGNED COMMENT '创建者'")
    private Long createdBy;

    @Column(name = "updated_at", nullable = false, insertable = false, updatable = false,
            columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间'")
    private LocalDateTime updatedAt;

    @Column(name = "updated_by", nullable = false,
            columnDefinition = "BIGINT UNSIGNED COMMENT '更新者'")
    private Long updatedBy;
}
